package service;

import java.math.BigDecimal;

public class Fruit {
    /**
     * 单价
     */
    protected double price;
    /*
    重量
     */
    protected int amount;
    /**
     * 单个产品折扣
     */
    protected double dis;

    public Fruit(double price, int amount, double dis) {
        this.price = price;
        this.amount = amount;
        this.dis = dis;
    }

    protected BigDecimal calculateEach(){
        BigDecimal one = BigDecimal.valueOf(price).setScale(3,BigDecimal.ROUND_HALF_EVEN);
        BigDecimal two = BigDecimal.valueOf(dis * amount).setScale(2,BigDecimal.ROUND_HALF_EVEN);
        return one.multiply(two).setScale(2,BigDecimal.ROUND_HALF_EVEN);
    }

}
